home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / x3270 / unix_files / globals.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-02-27  |  7.0 KB  |  262 lines

  1. /*
  2.  * Modifications Copyright 1993, 1994, 1995, 1996, 1999, 2000 by Paul Mattes.
  3.  * Copyright 1990 by Jeff Sparkes.
  4.  *  Permission to use, copy, modify, and distribute this software and its
  5.  *  documentation for any purpose and without fee is hereby granted,
  6.  *  provided that the above copyright notice appear in all copies and that
  7.  *  both that copyright notice and this permission notice appear in
  8.  *  supporting documentation.
  9.  */
  10.  
  11. /*
  12.  *    globals.h
  13.  *        Common definitions for x3270.
  14.  */
  15.  
  16. /* Optional parts. */
  17. #include "parts.h"
  18. #if defined(X3270_TN3270E) && !defined(X3270_ANSI) /*[*/
  19. #define X3270_ANSI    1    /* RFC2355 requires NVT mode */
  20. #endif /*]*/
  21.  
  22. /*
  23.  * OS-specific #defines.  Except for the blocking-connect workarounds, these
  24.  * should be replaced with autoconf probes as soon as possible.
  25.  */
  26.  
  27. /*
  28.  * BLOCKING_CONNECT_ONLY
  29.  *   Use only blocking sockets.
  30.  */
  31. #if defined(sco) /*[*/
  32. #define BLOCKING_CONNECT_ONLY    1
  33. #endif /*]*/
  34.  
  35. #if defined(apollo) /*[*/
  36. #define BLOCKING_CONNECT_ONLY    1
  37. #endif /*]*/
  38.  
  39. /*
  40.  * Compiler-specific #defines.
  41.  */
  42.  
  43. /* 'unused' explicitly flags an unused parameter */
  44. #if defined(__GNUC__) /*[*/
  45. #define unused __attribute__((__unused__))
  46. #else /*][*/
  47. #define unused /* nothing */
  48. #endif /*]*/
  49.  
  50.  
  51.  
  52. /*
  53.  * Prerequisite #includes.
  54.  */
  55. #include <stdio.h>            /* Unix standard I/O library */
  56. #include <stdlib.h>            /* Other Unix library functions */
  57. #include <unistd.h>            /* Unix system calls */
  58. #include <ctype.h>            /* Character classes */
  59. #include <string.h>            /* String manipulations */
  60. #include <sys/types.h>            /* Basic system data types */
  61. #include <sys/time.h>            /* System time-related data types */
  62. #include "localdefs.h"            /* {s,tcl,c}3270-specific defines */
  63. #include "conf.h"            /* autoconf settings */
  64.  
  65. /* Local process (-e) header files. */
  66. #if defined(X3270_LOCAL_PROCESS) && defined(HAVE_LIBUTIL) /*[*/
  67. #define LOCAL_PROCESS    1
  68. #include <termios.h>
  69. #if defined(HAVE_PTY_H) /*[*/
  70. #include <pty.h>
  71. #endif /*]*/
  72. #if defined(HAVE_LIBUTIL_H) /*[*/
  73. #include <libutil.h>
  74. #endif /*]*/
  75. #if defined(HAVE_UTIL_H) /*[*/
  76. #include <util.h>
  77. #endif /*]*/
  78. #endif /*]*/
  79.  
  80. /* Simple global variables */
  81.  
  82. extern int        COLS;
  83. extern int        ROWS;
  84. #if defined(X3270_DISPLAY) /*[*/
  85. extern Atom        a_3270, a_registry, a_iso8859, a_ISO8859, a_encoding,
  86.                 a_1;
  87. extern XtAppContext    appcontext;
  88. #endif /*]*/
  89. extern const char    *build;
  90. extern int        children;
  91. extern char        *connected_lu;
  92. extern char        *connected_type;
  93. extern char        *current_host;
  94. extern unsigned short    current_port;
  95. extern Boolean        *debugging_font;
  96. extern char        *efontname;
  97. extern Boolean        ever_3270;
  98. extern Boolean        exiting;
  99. extern Boolean        *extended_3270font;
  100. extern Boolean        flipped;
  101. extern char        *full_current_host;
  102. extern char        full_model_name[];
  103. extern char        *hostname;
  104. extern Boolean        *latin1_font;
  105. extern char        luname[];
  106. #if defined(LOCAL_PROCESS) /*[*/
  107. extern Boolean        local_process;
  108. #endif /*]*/
  109. extern int        maxCOLS;
  110. extern int        maxROWS;
  111. extern char        *model_name;
  112. extern int        model_num;
  113. extern Boolean        non_tn3270e_host;
  114. extern int        ov_cols, ov_rows;
  115. extern Boolean        passthru_host;
  116. extern char        *programname;
  117. extern char        *reconnect_host;
  118. extern int        screen_depth;
  119. extern Boolean        scroll_initted;
  120. extern Boolean        shifted;
  121. extern Boolean        *standard_font;
  122. extern Boolean        std_ds_host;
  123. extern char        *termtype;
  124. extern Widget        toplevel;
  125.  
  126. #if defined(X3270_DISPLAY) /*[*/
  127. extern Atom        a_delete_me;
  128. extern Atom        a_save_yourself;
  129. extern Atom        a_state;
  130. extern Display        *display;
  131. extern Pixmap        gray;
  132. extern Pixel        keypadbg_pixel;
  133. extern XrmDatabase    rdb;
  134. extern Window        root_window;
  135. #endif /*]*/
  136.  
  137. /* Data types and complex global variables */
  138.  
  139. /*   connection state */
  140. enum cstate {
  141.     NOT_CONNECTED,        /* no socket, unknown mode */
  142.     PENDING,        /* connection pending */
  143.     CONNECTED_INITIAL,    /* connected, no mode yet */
  144.     CONNECTED_ANSI,        /* connected in NVT ANSI mode */
  145.     CONNECTED_3270,        /* connected in old-style 3270 mode */
  146.     CONNECTED_INITIAL_E,    /* connected in TN3270E mode, unnegotiated */
  147.     CONNECTED_NVT,        /* connected in TN3270E mode, NVT mode */
  148.     CONNECTED_SSCP,        /* connected in TN3270E mode, SSCP-LU mode */
  149.     CONNECTED_TN3270E    /* connected in TN3270E mode, 3270 mode */
  150. };
  151. extern enum cstate cstate;
  152.  
  153. #define PCONNECTED    ((int)cstate >= (int)PENDING)
  154. #define HALF_CONNECTED    (cstate == PENDING)
  155. #define CONNECTED    ((int)cstate >= (int)CONNECTED_INITIAL)
  156. #define IN_NEITHER    (cstate == CONNECTED_INITIAL)
  157. #define IN_ANSI        (cstate == CONNECTED_ANSI || cstate == CONNECTED_NVT)
  158. #define IN_3270        (cstate == CONNECTED_3270 || cstate == CONNECTED_TN3270E || cstate == CONNECTED_SSCP)
  159. #define IN_SSCP        (cstate == CONNECTED_SSCP)
  160. #define IN_TN3270E    (cstate == CONNECTED_TN3270E)
  161. #define IN_E        (cstate >= CONNECTED_INITIAL_E)
  162.  
  163. /*   keyboard modifer bitmap */
  164. #define ShiftKeyDown    0x01
  165. #define MetaKeyDown    0x02
  166. #define AltKeyDown    0x04
  167.  
  168. /*   toggle names */
  169. struct toggle_name {
  170.     const char *name;
  171.     int index;
  172. };
  173. extern struct toggle_name toggle_names[];
  174.  
  175. /*   extended attributes */
  176. struct ea {
  177.     unsigned char fg;    /* foreground color (0x00 or 0xf<n>) */
  178.     unsigned char bg;    /* background color (0x00 or 0xf<n>) */
  179.     unsigned char gr;    /* ANSI graphics rendition bits */
  180.     unsigned char cs;    /* character set (GE flag, or 0..2) */
  181. };
  182. #define GR_BLINK    0x01
  183. #define GR_REVERSE    0x02
  184. #define GR_UNDERLINE    0x04
  185. #define GR_INTENSIFY    0x08
  186.  
  187. #define CS_MASK        0x03    /* mask for specific character sets */
  188. #define CS_GE        0x04    /* cs flag for Graphic Escape */
  189.  
  190. /*
  191.  * Lightpen select test macro, includes configurable override of selectability
  192.  * of highlighted fields.
  193.  */
  194. #define FA_IS_SEL(fa) \
  195.     (FA_IS_SELECTABLE(fa) && \
  196.      (appres.highlight_select || !FA_IS_INTENSE(fa)))
  197.  
  198. /*   translation lists */
  199. struct trans_list {
  200.     char            *name;
  201.     char            *pathname;
  202.     Boolean            is_temp;
  203.     Boolean            from_server;
  204.     struct trans_list    *next;
  205. };
  206. extern struct trans_list *trans_list;
  207.  
  208. /*   font list */
  209. struct font_list {
  210.     char            *label;
  211.     char            *font;
  212.     struct font_list    *next;
  213. };
  214. extern struct font_list *font_list;
  215. extern int font_count;
  216.  
  217. /*   input key type */
  218. enum keytype { KT_STD, KT_GE };
  219.  
  220. /*   state changes */
  221. #define ST_HALF_CONNECT    0
  222. #define ST_CONNECT    1
  223. #define ST_3270_MODE    2
  224. #define ST_LINE_MODE    3
  225. #define ST_REMODEL    4
  226. #define ST_PRINTER    5
  227. #define ST_EXITING    6
  228. #define N_ST        7
  229.  
  230. /* Naming convention for private actions. */
  231. #define PA_PFX    "PA-"
  232.  
  233. /* Shorthand macros */
  234.  
  235. #define CN    ((char *) NULL)
  236. #define PN    ((XtPointer) NULL)
  237.  
  238. /* Configuration change masks. */
  239. #define NO_CHANGE    0x0000    /* no change */
  240. #define MODEL_CHANGE    0x0001    /* screen dimensions changed */
  241. #define FONT_CHANGE    0x0002    /* emulator font changed */
  242. #define COLOR_CHANGE    0x0004    /* color scheme or 3278/9 mode changed */
  243. #define SCROLL_CHANGE    0x0008    /* scrollbar snapped on or off */
  244. #define CHARSET_CHANGE    0x0010    /* character set changed */
  245. #define ALL_CHANGE    0xffff    /* everything changed */
  246.  
  247. /* Portability macros */
  248.  
  249. /*   Equivalent of setlinebuf */
  250.  
  251. #if defined(_IOLBF) /*[*/
  252. #define SETLINEBUF(s)    setvbuf(s, (char *)NULL, _IOLBF, BUFSIZ)
  253. #else /*][*/
  254. #define SETLINEBUF(s)    setlinebuf(s)
  255. #endif /*]*/
  256.  
  257. /*   Motorola version of gettimeofday */
  258.  
  259. #if defined(MOTOROLA)
  260. #define gettimeofday(tp,tz)    gettimeofday(tp)
  261. #endif
  262.